<?php
namespace app\index\controller;

use think\Controller;

class Common extends Controller {
    public function index() {
        return $this->fetch();
    }

    public function indexBak() {
        return $this->fetch();
    }
    
    public function test() {
        $resPayBisOrder = model('PayBisOrder')->where([
            'merchant_id' => '1008235',
        ])->select();
        $amount = 0;
        $mchntFee = 0;
        for($i = 0; $i<count($resPayBisOrder); $i++){
            $amount += $resPayBisOrder[$i]->actual_amount;
            $mchntFee += $resPayBisOrder[$i]->mchnt_fee;
        }
        $all =  $amount + $mchntFee;
        return json_encode($all, true);
    }
    
    public function getip() {
        return isset($_SERVER["HTTP_X_FORWARDED_FOR"])?$_SERVER["HTTP_X_FORWARDED_FOR"]  
        :(isset($_SERVER["HTTP_CLIENT_IP"])?$_SERVER["HTTP_CLIENT_IP"]  
        :$_SERVER["REMOTE_ADDR"]);
    }
}
